/*
 * Data Mashup Canonical Model. A canonical model for representing data mashups
 * Copyright (C) 2011 Carlos Rodriguez
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package eu.ict_omelette.mashup.canonicalmodel;

import java.io.Serializable;

/**
 *
 * @author Carlos Rodriguez
 */
public class Dataflow implements Serializable, Cloneable {

    private String id;

    private Component fromComponent;
    private Component toComponent;

    private Port fromPortName;
    private Port toPortName;

    /**
     * @return the fromPort
     */
    public Port getFromPort() {
        return this.fromPortName;
    }

    /**
     * @param fromPort the fromPort to set
     */
    public void setFromPort(Component fromComponent, Port outputPort) {
        this.fromComponent = fromComponent;
        this.fromPortName = outputPort;
    }

    /**
     * @return the toPort
     */
    public Port getToPort() {
        return this.toPortName;
    }

    /**
     * @param toPort the toPort to set
     */
    public void setToPort(Component toComponent, Port inputPort) {
        this.toComponent = toComponent;
        this.toPortName = inputPort;
    }

    public Component getFromComponent(){
        return this.fromComponent;
    }

    public Component getToComponent(){
        return this.toComponent;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    @Override
    public Object clone(){
        try{
            Dataflow df = new Dataflow();

            df.fromComponent = this.fromComponent.clone();
            df.toComponent = this.toComponent.clone();
            df.fromPortName = (Port)this.fromPortName.clone();
            df.toPortName = (Port)this.toPortName.clone();

            return df;
        }catch(Exception e){
            return null;
        }
    }
    
}
